package userServlet.dao;

import userServlet.bean.User;
import userServlet.mysql.Mysql;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class ServletDaoImpl extends Mysql implements ServletDao {
    @Override
    public List<User> getUserInfo() {
        User user = null;
        try {
            String sql = "select userName,password from login";
            List<User> list = new ArrayList<>();
            ResultSet rs = query(sql,null);
            while(rs.next()){
                user = new User();
                user.setUserName(rs.getString("userName"));
                user.setPassword(rs.getString("password"));
                list.add(user);
            }
            return list;
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            closeAll();
        }
        return null;
    }
}
